package com.aat.dxfy.concurrent;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestExecutor extends Thread {
	private int index;

	public TestExecutor(int index) {
		this.index = index;
	}

	public void run() {
		try {
			System.out.println("[" + this.index + "] start....");
			Thread.sleep((int) (Math.random() * 1000));
			System.out.println("[" + this.index + "] end.");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		ExecutorService service=Executors.newFixedThreadPool(10);
		for (int i = 0; i < 10; i++) {
			service.execute(new TestExecutor(i));
			service.submit(new TestExecutor(i));
		}
		System.out.println("over");
		service.shutdown();
	}
	
}
